<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 策略类
      const strategies = {
        S: function (salary) {
          return salary * 4
        },
        A: function (salary) {
          return salary * 3
        },
        B: function (salary) {
          return salary * 2
        },
      }

      // 使用策略类计算奖金
      const calculateBonus = function (level, salary) {
        return strategies[level](salary)
      }

      console.log(calculateBonus('S', 10000)) // 40000
      console.log(calculateBonus('A', 10000)) // 30000
      console.log(calculateBonus('B', 10000)) // 20000
    </script>
  </body>
</html>
